<?php

/*
Setting up Pull My Finger (admin_setup_finger.pro.php)
*/

$rank_check = "7";
include "../global.inc.php";

$explodeCheap = explode(", ", $cheap_prizes);
$countCheap = count($explodeCheap) - 1;

for ($a = 0; $a <= $countCheap;)
{
	$findItem = fetch("SELECT * FROM items2 WHERE item_name = '$explodeCheap[$a]' AND game = '$game'");
	if (!$findItem[id])
	{
		die(header(error("admin_setup_finger.php?game=$game","The item \"$explodeCheap[$a]\" does not exsist!")));
	}
	$a++;
}

$explodeGood = explode(", ", $good_prizes);
$countGood = count($explodeGood) - 1;

for ($a = 0; $a <= $countGood;)
{
	if ($explodeGood[$a] <= 0)
	{
		die(header(error("admin_setup_finger.php?game=$game","The third box only allows values greater then 0. Remember, the third box is for Point Prizes, not items!")));
	}
	$a++;
}

$explodeGreat = explode(", ", $great_prizes);
$countGreat = count($explodeGreat) - 1;

for ($a = 0; $a <= $countGreat;)
{
	$findItem = fetch("SELECT * FROM items2 WHERE item_name = '$explodeGreat[$a]' AND game = '$game'");
	if (!$findItem[id])
	{
		die(header(error("admin_setup_finger.php?game=$game","The item \"$explodeGreat[$a]\" does not exsist!")));
	}
	$a++;
}

mysql_query("DELETE FROM finger_prizes WHERE game = '$game'");
mysql_query("INSERT INTO finger_prizes (cheap_finger,good_finger,great_finger,game) VALUES ('$cheap_prizes','$good_prizes','$great_prizes','$game')");

header(error("admin_setup_finger.php?game=$game","The game has been setup! You can now <a href=finger.php?game=$game>play</a>!!"));
?>
